package com.heking.securityapp.pages;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

import com.heking.security.webview.BaseWebViewClient;
import com.heking.security.webview.WebPageHelper;
import com.heking.securityapp.R;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * @Author 35574
 * @Date 2021/10/25
 * @Description
 */
public class WebViewActivity extends AppCompatActivity {

    private WebView mWebView;
    private WebPageHelper webPageHelper;
    private TextView mTvTitle;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.web_view_activity);
        findViews();
        webPageHelper=new WebPageHelper(mWebView,getIntent().getExtras());
        webPageHelper.setWebViewClient(new BaseWebViewClient() {
            @Override
            public void onLoading() {

            }

            @Override
            public void onLoadingFinish() {

            }
        });
        String title = webPageHelper.getTitle();
        if(title!=null){
            mTvTitle.setText(title);
        }else{
            mTvTitle.setVisibility(View.GONE);
        }
        webPageHelper.load();
    }


    private void findViews() {
        mWebView = findViewById(R.id.webView);
        mTvTitle = findViewById(R.id.tv_title);
    }

    @Override
    public void onBackPressed() {
        webPageHelper.onBackPressed(this);
    }


}
